package com.zige.zige.constants;

import java.util.UUID;

import com.zige.zige.pojo.Member;
import com.zige.zige.utils.PreferencesUtils;
import com.zige.zige.utils.StringUtils;

import android.content.Context;
import android.graphics.Typeface;
import android.os.Environment;
import android.telephony.TelephonyManager;

public class Constants {

	// Sharedpreference name
	public static final String PREFERENCE_NAME = "LittleZebraSP";
	/** 是否允许非WIFI网络中播放视频 */
	public static final String PREFERENCE_KEY_IS_WIFI_ONLY = "isWIFIOnly";
	/** 登录token */
	public static final String PREFERENCE_KEY_LOGIN_TOKEN = "loginToken";
	public static final String PREFERENCE_KEY_LOGIN_ACCOUNT = "loginaccount";
	public static final String PREFERENCE_KEY_LOGIN_PASSWORD = "loginpassword";
	public static final String PREFERENCE_KEY_LOGIN_TYPE = "logintype";
	public static final String PREFERENCE_KEY_USER_ID = "userid";
	/** 登录用户familyID */
	public static final String PREFERENCE_KEY_LOGIN_FAMILY_ID = "familyid";
	/** 登录用户memberID */
	public static final String PREFERENCE_KEY_LOGIN_MEMBER_ID = "memberid";
	/** 7牛domain */
	public static final String PREFERENCE_KEY_7_NIU_DOMAIN = "7niudomain";
	public static final String VERSION_PLATFORM = "android";

	// haibang
	public static final String URL_SERVER = "http://115.159.123.33:60/";
	// public static final String URL_ZIGE_APP_PATH = "app/common/";
	// kangmin
	// public static final String URL_SERVER = "http://192.168.1.92:8080/";
	/** 测试服务器 */
	// public static final String URL_SERVER = "http://115.159.123.33:8099/";
	/** 生产服务器地址 */
	// public static final String URL_SERVER = "http://115.159.123.33/";
	/** 应用路径 */
	// public static final String URL_ZIGE_APP_PATH = "zige-app/app/";

	/** 检查版本接口 */
	public static final String URL_CHECK_VERSION = URL_SERVER + "/app/common/openClient?";
	/** 用户注册接口 */
	public static final String URL_USER_REGIST = URL_SERVER + "/app/user/register?";
	/** 用户登录接口 */
	public static final String URL_USER_LOGIN_WITH_TOKEN = URL_SERVER + "zige_0003?";
	/** 用户预登录接口 */
	public static final String URL_USER_LOGIN = URL_SERVER + "/app/user/login?";
	public static final String URL_GET_TAGLIST = URL_SERVER + "/app/common/tagList?";
	public static final String URL_PROFILE_COMPLETE = URL_SERVER + "/app/user/infoComplete?";
	/** 获取推荐视频列表接口 */
	public static final String URL_GET_VIDEO_LIST = URL_SERVER + "activityAndVideo?";

	/** 获取7牛上传token接口 */
	public static final String URL_GET_7NIU_TOKEN = URL_SERVER + "/app/common/getQiniuToken?";
	/** 上传视频 */
	public static final String USER_UPLOAD_VIDEO = URL_SERVER + "/app/timeMachine/userUploadVideo";


	/** 自动登录接口 */
	public static final String URL_USER_LOGIN_AUTO = URL_SERVER + "zige_0007?";
	/** 用户登出接口 */
	public static final String URL_USER_LOGIN_OUT = URL_SERVER + "zige_0008?";
	/** 发送消息 */
	public static final String URL_SEND_MESSAGE = URL_SERVER + "zige_0009?";
	/** 推送回执 */
	public static final String URL_MESSAGE_ACK = URL_SERVER + "zige_0010?";
	/** 未读消息查询 */
	public static final String URL_CHECK_MESSAGE = URL_SERVER + "zige_0011?";
	public static final String URL_UPLOAD_VIDEO = URL_SERVER + "zige_0012?";
	public static final String URL_FEED_BACK = URL_SERVER + "zige_0013?";
	public static final String URL_SEND_MSG_CODE = URL_SERVER + "/app/common/smsGenerate?";
	public static final String URL_VERIFY_MSG_CODE = URL_SERVER + "zige_0015?";
	public static final String URL_CHANGE_PASSWORD = URL_SERVER + "zige_0016?";
	public static final String URL_USER_PROFILE = URL_SERVER + "zige_0017?";
	public static final String URL_DELETE_VIDEO = URL_SERVER + "zige_0019?";
	/** 检查版本接口 */
	// public static final String URL_CHECK_VERSION = "zige_0005?";

	public static final String TENCENT_CLOUD_HOST = "vod.qcloud.com/";
	public static final String TENCENT_QUERY = "v2/index.php";
	public static final String TENCENT_SECRET_ID = "AKIDI3BK9pbIPoO0NIrQyU2gIN3caJaSrfpB";
	public static final String TENCENT_SECRET_KEY = "tgmfiMbNxohjxsWpK9yG5b8VBTYVfGNJ";

	public static final String FILE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath()
			+ "/LittleZebra/";
	public static final String VIDEO_PATH = FILE_PATH + "video/";
	public static final String IMAGE_PATH = FILE_PATH + "image/";
	public static final String VOICE_PATH = FILE_PATH + "voice/";

	private static Typeface typerFace;

	public static Typeface gettyperFace() {
		return typerFace;
	}

	public static void setTyperface(Typeface t) {
		typerFace = t;
	}

	private static Member currentMember;

	public static Member getCurrentMember() {
		return currentMember;
	}

	public static void setCurrentMember(Member currentM) {
		if (currentM != null)
			currentMember = currentM;
	}

	public static String createUUID() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}

	public static String getImei(Context context) {
		String Imei = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
		return !StringUtils.isBlank(Imei) ? Imei.toLowerCase() : "";
	}

	public static String getAccount(Context context) {
		return PreferencesUtils.getString(context, PREFERENCE_KEY_LOGIN_ACCOUNT);
	}
	public static void setAccount(Context context, String acc) {
		PreferencesUtils.putString(context, PREFERENCE_KEY_LOGIN_ACCOUNT, acc);
	}

	public static String getPassword(Context context) {
		return PreferencesUtils.getString(context, PREFERENCE_KEY_LOGIN_PASSWORD);
	}
	public static void setPassword(Context context, String pass) {
		PreferencesUtils.putString(context, PREFERENCE_KEY_LOGIN_PASSWORD, pass);
	}

	public static String getLoginType(Context context) {
		return PreferencesUtils.getString(context, PREFERENCE_KEY_LOGIN_TYPE);
	}
	
	public static String getUID(Context context) {
		return PreferencesUtils.getString(context, PREFERENCE_KEY_USER_ID);
	}
	public static void setUID(Context context, String id) {
		PreferencesUtils.putString(context, PREFERENCE_KEY_USER_ID, id);
	}

	public static String getToken(Context context) {
		return PreferencesUtils.getString(context, PREFERENCE_KEY_LOGIN_TOKEN);
	}

	public static int getFamlyID(Context context) {
		return PreferencesUtils.getInt(context, PREFERENCE_KEY_LOGIN_FAMILY_ID);
	}

	public static int getMemberID(Context context) {
		return PreferencesUtils.getInt(context, PREFERENCE_KEY_LOGIN_MEMBER_ID);
	}

	public static void removeToken(Context context) {
		PreferencesUtils.remove(context, PREFERENCE_KEY_LOGIN_TOKEN);
		PreferencesUtils.remove(context, PREFERENCE_KEY_LOGIN_FAMILY_ID);
		PreferencesUtils.remove(context, PREFERENCE_KEY_LOGIN_MEMBER_ID);
		PreferencesUtils.remove(context, PREFERENCE_KEY_LOGIN_ACCOUNT);
	}

	public static String get7niuDoMain(Context context) {
		return PreferencesUtils.getString(context, PREFERENCE_KEY_7_NIU_DOMAIN);
	}

	public static int memberId = -1;

}
